#! /usr/bin/env python

import mathex


def main():
    maxsn = 0
    for i in range(1,9876):
        for n in range(1,10):
            sn = ''.join([ str(i*k) for k in range(1,n+1)])
            sn1 = [c for c in sn]
            sn1.sort()
            if ''.join(sn1) == '123456789' and int(sn)>maxsn:
                maxsn=int(sn)


    print maxsn
if __name__ == '__main__':
    main()
    
